/**
 * 
 */
package neptune.web.client.view.components.editor;

import neptune.web.client.model.topology.SerializableNetworkInterface;
import neptune.web.client.model.topology.SerializableNode;
import neptune.web.client.model.topology.SerializableTopology;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.TreeItem;

/**
 * @author Roberto Bifulco [info@RobertoBifulco.it] [RobertoBifulco.it]
 * 
 */
public class AddControlNetIFGraphicCommand implements Command {

	private TreeItem item;
	private SerializableNetworkInterface netIf;

	private final SerializableNode node;
	private final SerializableTopology topology;

	/**
	 * 
	 * @param netIf
	 * @param node
	 * @param item
	 *            of the node containing this interface
	 */
	public AddControlNetIFGraphicCommand(SerializableNetworkInterface netIf,
			SerializableNode node, SerializableTopology topology, TreeItem item) {
		this.netIf = netIf;
		this.node = node;
		this.topology = topology;
		this.item = item;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.google.gwt.user.client.Command#execute()
	 */
	public void execute() {
		final TreeItem netIfItem = new TreeItem();
		netIfItem.setWidget(new ControlNetIFMenuBar(netIf, node, topology,
				netIfItem));
		item.getChild(0).addItem(netIfItem);
	}

}
